package com.zjitc.servlet;

import com.zjitc.pojo.Customer;
import com.zjitc.service.CustomerService;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/15 16:30
 * @description:
 */
@WebServlet(name = "DisplayServlet",urlPatterns = "/display")
public class DisplayServlet extends HttpServlet {


  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    CustomerService customerService = new CustomerService();
    try {
      List<Customer> display = customerService.display();

      request.setAttribute("display",display);
      request.getRequestDispatcher("/display.jsp").forward(request,response);
    } catch (SQLException e) {
      e.printStackTrace();
    }

  }
}
